package com.fengdi.everyday.middle;

/**
 * @Description 75 颜色分类
 * @Date 08:39
 */
public class SortColor {
    public void sortColors(int[] nums) {
        int[] counter = new int[3];

        for (int num : nums) {
            switch (num) {
                case 0:
                    counter[0] += 1;
                    break;
                case 1:
                    counter[1] += 1;
                    break;
                case 2:
                    counter[2] += 1;
                    break;
            }
        }

        int index = 0;
        for(int k = 0; k < 3; k++) {
            for(int i = 0; i < counter[k]; i++) {
                nums[index] = k;
                index++;
            }
        }
    }
}
